import request from "@/utils/request";

import { type Message } from "@/types/WebEssay"
enum API {
    base_essay = '/web/essay',
    base_music = '/web/music',
    base_video = '/web/video',
    base_recommend = '/web/recommend',
    base_essayDetail = '/web/essayOne',
    base_videoDetail = '/web/videoOne',
    base_ablums = '/web/ablums',
    base_tale = '/web/talk',
    base_talk_year = '/web/talkyear/count',
    base_ablums_year = '/web/albums/count',
    base_admin = '/web/admin',
    base_counts = '/web/counts',
    base_message = "/web/message",
    base_login = '/commonUser/login',
    base_add_views = '/web/essay/inc',
    base_add_discuss = '/web/essay/disCount',
    base_add_video = '/web/video/inc',
    base_add_video_discuss = '/web/video/disCount',
    base_search = '/web/search'
}
//获取文章列表
export const Get_essay_list = (category: number, skp: number) => request({
    method: "get",
    url: API.base_essay + `/${category}/${skp}`
})
//获取音乐列表
export const Get_music_list = (id: number) => request({
    method: "get",
    url: API.base_music + `/${id}`
})

//获取单个音乐
export const Get_one_music = (skp: number) => request({
    method: "get",
    url: API.base_music + `/one/${skp}`
})
//获取视频文章列表
export const Get_video_list = (id: number) => request({
    method: "get",
    url: API.base_video + `/${id}`
})
//获取推荐文章信息
export const Get_recommend = () => request({
    method: "get",
    url: API.base_recommend
})
//获取单个文章信息
export const Get_essaay_detail = (id: string) => request({
    method: "get",
    url: API.base_essayDetail + `/${id}`

})
//获取单个视频文章信息
export const Get_video_detail = (id: string) => request({
    method: "get",
    url: API.base_videoDetail + `/${id}`
})
//获取相册列表
export const Get_ablums_list = (data: { year: number, month: number }) => request({
    method: "get",
    url: API.base_ablums + `/${data.year}/${data.month}`,

})


//获取说说列表
export const Get_talk_list = (skp: number, type_year: number) => request({
    method: "get",
    url: API.base_tale + `/${skp}/${type_year}`
})
//获取不同年份 
export const Get_talk_diffrent_year = () => request({
    method: "get",
    url: API.base_talk_year
})

//获取相册不同年份
export const Get_ablums_diffrent_year = () => request({
    method: "GET",
    url: API.base_ablums_year
})


export const Get_admin_info = () => request({
    method: "get",
    url: API.base_admin
})

export const get_total = () => request({
    method: 'get',
    url: API.base_counts
})

export const add_message = (data: Message) => request({
    method: "post",
    url: API.base_message,
    data

})

export const get_messages = () => request({
    method: "get",
    url: API.base_message
})


export const loginuser = (data: { username: string, password: string }) => request({
    method: "post",
    url: API.base_login,
    data
})

//浏览记录增加文本文章
export const add_views = (id: string) => request({
    method: "post",
    url: API.base_add_views + `/${id}`
})

//浏览记录增加视频文章
export const add_views_video = (id: string) => request({
    method: "post",
    url: API.base_add_video + `/${id}`
})

//增加视频文章记录
export const add_view_disscuss = (id: string) => request({
    method: "post",
    url: API.base_add_video_discuss + `/${id}`
})
//增加文章评论
export const add_discuss_count = (id: string) => request({
    method: "post",
    url: API.base_add_discuss + `/${id}`
})


export const search = (word: string) => request({
    method: "post",
    url: API.base_search,
    data: {
        word: word
    }
})